package com.stone.business.zbtz.action;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import com.stone.business.zbtz.pojo.TZbtz;
import com.stone.business.zbtz.service.ZbtzService;
import com.stone.sys.pojo.TOrgan;
import com.stone.utils.StringUtils;

import frm.ssh.action.BaseListAction;

public class ZbtzListAction extends BaseListAction {

	private ZbtzService zbtzService;
	 //班组
	private List<TOrgan> bzList;
	@Override
	public HashMap<String, Object> setSearchCondition() {
		HashMap<String, Object> m = new HashMap<String, Object>();
		
		List<Object> valsList = new ArrayList<Object>();
		
		m.put("cols", " a ");
		
		String conditions = " 1=1 "; 
		String cxrq="";
		if(super.getSearchBean().getCon6().equals("1")){
			cxrq="a.startdate";
		}else{
			cxrq="a.startdate";
		}
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon2())) {
			conditions += " AND TO_CHAR("+cxrq+",'yyyy-MM-dd') >= ?";
			valsList.add(super.getSearchBean().getCon2());
		}
		
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon3())) {
			conditions += " AND TO_CHAR("+cxrq+",'yyyy-MM-dd') <= ?";
			valsList.add(super.getSearchBean().getCon3());
		}
		
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon4())) {
			conditions += " AND bzid = ?";
			valsList.add(super.getSearchBean().getCon4());
		}
		if (!StringUtils.isNullOrBlankFull(super.getSearchBean().getCon6())) {
			conditions += " AND dantype = ?";
			valsList.add(super.getSearchBean().getCon6());
		}
		// 查询条件
		m.put("conditions",conditions);
		m.put("alias", " a ");
		m.put("vals", valsList.toArray());
		String forword="";
		if(super.getSearchBean().getCon6().equals("1")){
			forword="WJ_SUCCESS";
			m.put("clause", " order by a.startdate Desc");
		}else if(super.getSearchBean().getCon6().equals("2")){
			forword="XJ_SUCCESS";
			m.put("clause", " order by a.startdate Desc");
		}
		else if(super.getSearchBean().getCon6().equals("3"))
		{
				forword="DYJ_SUCCESS";
				m.put("clause", " order by a.startdate Desc");
			}else if(super.getSearchBean().getCon6().equals("3"))
		{
				forword="GRGQJ_SUCCESS";
				m.put("clause", " order by a.startdate Desc");
			}else{
			forword="BZGQJ_SUCCESS";
			m.put("clause", " order by a.startdate Desc");
		}
		 //班组
	 	String bzsql = "from TOrgan where id <=24 and id >=21 order by id";
	 	bzList = zbtzService.findListByHql(bzsql);
		m.put("forward", forword);
		
		return m;
	}
	public ZbtzService getZbtzService() {
		return zbtzService;
	}
	public void setZbtzService(ZbtzService zbtzService) {
		this.zbtzService = zbtzService;
		this.service=zbtzService;
	}
	public ZbtzListAction() {
		this.entityClass = TZbtz.class;
	}
	public List<TOrgan> getBzList() {
		return bzList;
	}
	public void setBzList(List<TOrgan> bzList) {
		this.bzList = bzList;
	}
	

}
